﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace dbPoll_Application.Models
{
    public class NumericQuestion : ShortResponseQuestion
    {
        [Required(ErrorMessage = "Minimum value is required")]
        [RegularExpression(@"^-?[0-9]+$", ErrorMessage = "Invalid minimum value")]
        public virtual int greaterThan { get; set; }
        [Required(ErrorMessage = "Maximum value is required")]
        [RegularExpression(@"^-?[0-9]+$", ErrorMessage = "Invalid maximum value")]
        public virtual int lessThan { get; set; }

        public NumericQuestion()
        {
            this.questionID = -1;
            this.question = String.Empty;
            this.creationTime = DateTime.Now;
            this.deletionTime = null;
            this.questionNumber = -1;
            this.type = QuestionType.None;
            this.fontType = "Helvetica";
            this.fontColour = "#000000";
            this.fontSize = 30;
            this.feedback = null;
            this.resultsChart = null;
            this.comparisonChart = null;
            this.asynchronous = true;
            this.responded = null;
            this.countdownTimer = null;
            this.responseCounter = null;
            this.correctAnswerIndicator = null;
            this.responseGrid = null;
            this.responses = null;
            this.greaterThan = -1;
            this.lessThan = -1;
        }

        public NumericQuestion(int questionNumber)
        {
            this.questionID = -1;
            this.question = String.Empty;
            this.creationTime = DateTime.Now;
            this.deletionTime = null;
            this.questionNumber = questionNumber;
            this.type = QuestionType.Numeric;
            this.fontType = "Helvetica";
            this.fontColour = "#000000";
            this.fontSize = 30;
            this.feedback = new HashSet<Feedback>();
            this.resultsChart = new QuestionChart("Vertical Bar", "Percentage", "green, orange, yellow, red", true);
            this.comparisonChart = new QuestionChart("Vertical Bar", "Percentage", "green, orange, yellow, red", false);
            this.asynchronous = true;
            this.responded = new HashSet<Participant>();
            this.countdownTimer = new CountdownTimer(false, 30);
            this.responseCounter = new ResponseCounter(false);
            this.correctAnswerIndicator = new CorrectAnswerIndicator(false);
            this.responseGrid = new ResponseGrid(false, "Name");
            this.responses = new HashSet<ShortResponse>();
            this.greaterThan = -1;
            this.lessThan = -1;
        }

        public NumericQuestion(int questionNumber, String fontType, String fontColour, int fontSize, QuestionChart resultsChart, CountdownTimer countdownTimer, ResponseCounter responseCounter, CorrectAnswerIndicator correctAnswerIndicator, ResponseGrid responseGrid)
        {
            this.questionID = -1;
            this.question = String.Empty;
            this.creationTime = DateTime.Now;
            this.deletionTime = null;
            this.questionNumber = questionNumber;
            this.type = QuestionType.Numeric;
            this.fontType = fontType;
            this.fontColour = fontColour;
            this.fontSize = fontSize;
            this.feedback = new HashSet<Feedback>();
            this.resultsChart = new QuestionChart(resultsChart);
            this.comparisonChart = new QuestionChart(resultsChart);
            this.asynchronous = true;
            this.responded = new HashSet<Participant>();
            this.countdownTimer = new CountdownTimer(countdownTimer);
            this.responseCounter = new ResponseCounter(responseCounter);
            this.correctAnswerIndicator = new CorrectAnswerIndicator(correctAnswerIndicator);
            this.responseGrid = new ResponseGrid(responseGrid);
            this.responses = new HashSet<ShortResponse>();
            this.greaterThan = -1;
            this.lessThan = -1;
        }
    }
}
